(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.sysNote.viewController', viewController);
	viewController.$inject = [ '$scope', 'Constants', 'layoutConfig', 'validatorConfig', 'gridService', 'authService', 'sysNoteService' ];
	function viewController($scope, Constants, layoutConfig, validatorConfig, gridService, authService, sysNoteService) {
		var ctrl = this, sysNoteInfo = $scope.$stateParams.params;
		ctrl.layoutConfig = layoutConfig;
		ctrl.sysNote = {};

		ctrl.init = function() {
			ctrl.innerGridOptions = gridService.createInnerGridOptions($scope, ctrl.layoutConfig.formConfigs.noteMsgsCfg.tableConfigs.table, rowSelectionChanged);
			ctrl.innerGridOptions.enableRowHeaderSelection = false;
			ctrl.innerGridOptions.data = 'vm.sysNote.noteMsgs';
			return authService.view(sysNoteInfo).then(function(response) {
				ctrl.sysNote = response.data || sysNoteInfo;
				ctrl.sysNote.noteMsgs = ctrl.sysNote.noteMsgs || [];
			}, angular.noop);
		};
		
		function rowSelectionChanged(eventRow, selectedRows) {
			ctrl.selectedMessages = selectedRows;
		}
	}
})(angular);